#version 300 es                           
precision mediump float;

in vec3 color;
in float elapsedtime;

uniform sampler2D u_sampler;

out vec4 o_color;

void main()                               
{
	// just to see two effect
	if (elapsedtime < 3.0) {
		// to change the point from quad to circle, the result turn beautifull
		// <0.5, 0.5> is the origin of the circle
		float xdistance = 0.5 - gl_PointCoord.s;
		float ydistance = 0.5 - gl_PointCoord.t;
		float distance_from_center = sqrt(xdistance*xdistance + ydistance*ydistance); // the distance to the circle origin

		if (distance_from_center > 0.1) // discard fragment which is not in the circle
			discard;
		else
			o_color = vec4(color / elapsedtime, 1.0);
	} else {
		o_color = vec4(color / elapsedtime, 1.0) * texture(u_sampler, gl_PointCoord);
	}
}
